<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
</head>
<body>

  <div id='app'>
    <home></home>
  </div>

<template id="tpl">
  <div>
    <h2>我是HOME页</h2>
    <common-head :a="2" b="你好" c="..."></common-head>
  </div>
</template>

<script src='https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js'></script>
<script>
  const CommonHead ={
    template: `
      <div>
        公共头部组件
        {{a}}
        {{b}}
        {{c}}
        {{d}}
        <button v-for="item in e" :key="item">{{item}}</button>
      </div>
    `
    // properties  怎么接收
    ,props: {
      // 只验证类型
      a: Number
      // 只验证类型，类型是数组中的一个即可
      ,b: [String, Number]
      // 验证类型，且为必传
      ,c: {
        type: String
        ,required: true
      }
      // 验证类型，并设置默认值
      ,d:{
        type: String
        ,default: '默认值'
      }
      ,e:{
        type:Array
        ,default: () => [1,2,3]
      }
    }
  }
  const Home = {
    template: "#tpl"
    ,components: {
      CommonHead
    }
    ,data() {
      return {
        homeTitle: '我是data定义的hemo标题'
      }
    }
  }
  Vue.component("Home", Home)
  const app = new Vue({
    el: '#app'
    ,data: {
      msg: 'Hello Vue'
    }
  })
</script>
</body>
</html>